<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="/js/layui/css/layui.css" media="all">
  <script src="/js/jquery-2.2.4.js" type="text/javascript"></script>
</head>
<body>
<form class="layui-form" id="ifrom">

      <input type="hidden" name="shop_info_id" id="shop_info_id"  lay-verify="title" autocomplete="off" placeholder="请输入标题" class="layui-input">
  <input type="hidden" name="version" id="version"  lay-verify="title" autocomplete="off" placeholder="请输入标题" class="layui-input">

  <div class="layui-form-item">
    <label class="layui-form-label">商品名称</label>
    <div class="layui-input-block">
      <input type="text" name="shop_info_name" id="shop_info_name" lay-verify="title" autocomplete="off" placeholder="请输入标题" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">商品价格</label>
    <div class="layui-input-block">
      <input type="text" name="shop_info_price" id="shop_info_price" lay-verify="title" autocomplete="off" placeholder="请输入标题" class="layui-input">
    </div>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label">商品备注</label>
    <div class="layui-input-block">
      <input type="text" name="shop_info_remark" id="shop_info_remark" lay-verify="title" autocomplete="off" placeholder="请输入标题" class="layui-input">
    </div>
  </div>
<!--  <div class="layui-form-item">-->
<!--    <label class="layui-form-label">版本号</label>-->
<!--    <div class="layui-input-block">-->
<!--      <input type="text" name="version" id="version" lay-verify="title" autocomplete="off" placeholder="请输入标题" class="layui-input">-->
<!--    </div>-->
<!--  </div>-->
  <div class="layui-form-item">
    <div class="layui-input-block">
      <button type="button" class="layui-btn" id="btn" >立即提交</button>
      <button type="submit" class="layui-btn layui-btn-primary">重置</button>
    </div>
  </div>
</form>

</body>
<script>

  //获取父页面的全局变量users
  let users = parent.window.users;
  $("#shop_info_id").val(users.shop_info_id);
  $("#shop_info_name").val(users.shop_info_name);
  $("#shop_info_price").val(users.shop_info_price);
  $("#shop_info_remark").val(users.shop_info_remark);
  $("#version").val(users.version);

  $("#btn").click(function(){

    $.ajax({
      async:false,//同步
      url:'/shopInfo/upd',//提交地址
      type:'post',//提交方式
      data:$("#ifrom").serialize(),//表单序列化
      dataType:'json',//转换数据类型
      success:function(data){//成功之后返回的数据
        if (data.code=='1'){
          alert("修改成功");
          var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
          parent.layer.close(index); //再执行关闭
          parent.location.reload();
        }else {
          alert("修改失败")
        }
      }
    })
  });

</script>
</html>